﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace Watki
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Thread watek;
        private void Form1_Load(object sender, EventArgs e)
        {
            MessageBox.Show(Dane.X.ToString());
            watek = new Thread(new ThreadStart(funkcja));
            Dane.X = 57;
            watek.IsBackground = true;
            watek.Start();
            Dane.X = 5436;
            Thread.CurrentThread.Name = "1";
        }

        private void funkcja()
        {
            Dane.Zmieniono += new Zmiana(Dane_Zmieniono);
            Dane.X = 35424;
            MessageBox.Show(Dane.X.ToString());
            Thread.CurrentThread.Name = "2";
        }

        void Dane_Zmieniono()
        {
            MessageBox.Show(Thread.CurrentThread.Name);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Dane.X = Convert.ToInt32(textBox1.Text);
        }
    }
}
